﻿Public Class ViewParametrerNouvelleGeneration

    Private Sub ngenDgrid_AutoGeneratingColumn(sender As Object, e As Windows.Controls.DataGridAutoGeneratingColumnEventArgs) Handles ngenDgrid.AutoGeneratingColumn
        If e.PropertyName.ToLower() = "groupe" Then e.Column.IsReadOnly = True
        If e.PropertyName.ToLower() = "code_garantie" Then e.Column.IsReadOnly = True
    End Sub

    Private Sub MenuItem_Modifier_Valeurs_Click(sender As Object, e As Windows.RoutedEventArgs)
        Dim inputdata As New ViewModelInputBox
        PMTModule.UIService.ShowMessage(inputdata)

        If String.IsNullOrEmpty(inputdata.Value) Then Return
        If String.IsNullOrEmpty(inputdata.Value.Trim()) Then Return

        Dim value As Double

        If inputdata.Value.Trim().Contains("%") Then
            value = Convert.ToDouble(inputdata.Value.Trim().Replace("%", "").Trim()) / 100.0
        Else
            value = Convert.ToDouble(inputdata.Value.Trim())
        End If

        For Each elt In ngenDgrid.SelectedCells
            Dim row As DataRowView = elt.Item

            If elt.Column.Header.ToString().ToLower() <> "groupe" And elt.Column.Header.ToString() <> "code_garantie" Then
                row.Row(elt.Column.Header.ToString()) = value
            End If
        Next
    End Sub
End Class
